home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / Technical Documentation / Develop / develop Issue 26 / develop Issue 26 code / SOM and ListPart / ListPart DR4 / Source / ListPartUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-03  |  6.2 KB  |  276 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ListPartUtils.h
  3.  
  4.     Contains:    ListPart utility functions & classes
  5.  
  6.     Written by:    Steve Smith
  7.  
  8.     Copyright:    © 1994,95 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11.  
  12. #ifndef _LISTPARTUTILS_
  13. #define _LISTPARTUTILS_
  14.  
  15. // --- ListPart Includes ---
  16.  
  17. #ifndef _LISTPART_
  18. #include "ListPart.h"
  19. #endif
  20.  
  21. #ifndef _SAMPLECOLLECTIONS_
  22. #include "SampleCollections.h"
  23. #endif
  24.  
  25. // --- OpenDoc Includes ---
  26.  
  27. #ifndef _ODTYPES_
  28. #include <ODTypes.h>
  29. #endif
  30.  
  31. #ifndef SOM_ODFrame_xh
  32. #include <Frame.xh>
  33. #endif
  34.  
  35. // --- OpenDoc Utilities ---
  36.  
  37. #ifndef _ITEXT_
  38. #include <IText.h>
  39. #endif
  40.  
  41. #ifndef _ODUTILS_
  42. #include <ODUtils.h>
  43. #endif
  44.  
  45. #ifndef _ODDEBUG_
  46. #include <ODDebug.h>
  47. #endif
  48.  
  49. #ifndef _TEMPOBJ_
  50. #include <TempObj.h>
  51. #endif
  52.  
  53. // --- Macintosh Includes ---
  54.  
  55. #ifndef __TYPES__
  56. #include <Types.h>
  57. #endif
  58.  
  59. // --- Forward Declarations ---
  60. class ODDraft;
  61. class ODFacet;
  62. class ODWindow;
  63. class ODStorageUnitView;
  64.  
  65. //------------------------------------------------------------------------------
  66. // Function Prototypes
  67. //------------------------------------------------------------------------------
  68.  
  69. ODIText*        GetPartName(Environment* ev, ODPart* part, ODType category);
  70. ODBoolean        NamesAreEquivalent(Environment* ev, ODIText* fileName,
  71.                                         ODIText* partName);
  72. void            GetEditorScriptLanguage(Environment* ev, ACF_DevServ_som_ListPart* fsomSelf, ODScriptCode* script,
  73.                                         ODLangCode* language);
  74. void            FixedToIntRect(ODRect& fixedRect, Rect& intRect);
  75. void            IntToFixedRect(Rect& intRect, ODRect& fixedRect);
  76. void            LoadThumbnail(Environment* ev, ACF_DevServ_som_ListPart* fsomSelf, Handle* thumbnail);
  77. Rect            TilePartWindow(Environment* ev, Rect* facetBounds,
  78.                                         Rect* partWindowBounds);
  79. ODUShort        CountFramesFacets(Environment* ev, ODFrame* frame);
  80.                                         
  81. //------------------------------------------------------------------------------
  82. // Utility Class Definitions
  83. //------------------------------------------------------------------------------
  84.  
  85. class CFrameProxy // (aka CFuton)
  86. {
  87.     public:
  88.     CFrameProxy();
  89.     ~CFrameProxy();
  90.     
  91.     void        InitFrameProxy(ODID frameID, ODDraft* draft);
  92.     void        InitFrameProxy(Environment* ev, ODFrame* frame);
  93.     void        Purge(Environment* ev);
  94.  
  95.     ODFrame*    GetFrame(Environment* ev);
  96.     void        SetFrame(Environment* ev, ODFrame* frame);
  97.     ODBoolean    FrameIsLoaded();
  98.     ODID        GetID();
  99.     ODDraft*    GetDraft();
  100.     
  101.     private:
  102.     ODFrame*    fFrame;
  103.     ODID        fID;
  104.     ODDraft*    fDraft;
  105. };
  106.  
  107. class CFrameInfo
  108. {
  109.     public:
  110.             CFrameInfo(ODSession* session);
  111.             ~CFrameInfo();
  112.     
  113.     void    Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
  114.     void    CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
  115.     void    ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
  116.                                     ODDraftKey key, ODFrame* scopeFrame);
  117.     void    CloneInto(Environment *ev, ODDraftKey key,
  118.                                     ODStorageUnitView* storageUnitView,
  119.                                     ODFrame* scopeFrame);
  120.     void    InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
  121.                 
  122.     ODBoolean        IsFrameActive();
  123.     void            SetFrameActive(ODBoolean active);
  124.     ODBoolean        FrameNeedsReactivating();
  125.     void            SetFrameReactivate(ODBoolean reactivate);
  126.     ODFacet*        GetActiveFacet();
  127.     void            SetActiveFacet(ODFacet* facet);
  128.     void            SetSourceFrame(Environment* ev, ODFrame* frame);
  129.     ODFrame*        GetSourceFrame(Environment* ev);
  130.     void            ReleaseSourceFrame(Environment* ev);
  131.     ODBoolean        HasSourceFrame();
  132.     ODWindow*        AcquirePartWindow(Environment* ev);
  133.     void            SetPartWindow(Environment* ev, ODWindow* window);
  134.     void            SetDependentFrame(Environment* ev, ODFrame* frame);
  135.     ODFrame*        GetDependentFrame(Environment* ev);
  136.     ODBoolean        HasDependentFrame();
  137.     void            ReleaseDependentFrame(Environment* ev);
  138.     void            SetShouldDisposeWindow(ODBoolean should);
  139.     ODBoolean        ShouldDisposeWindow();
  140.     
  141.     private:
  142.     CFrameInfo(); /* don't want parts to call */
  143.     
  144.     ODSession*        fSession;
  145.  
  146.     ODBoolean        fFrameActive;
  147.     ODBoolean        fFrameReactivate;
  148.     ODBoolean        fShouldDisposeWindow;
  149.     ODFacet*        fActiveFacet;
  150.     CFrameProxy*    fSourceFrame;
  151.     CFrameProxy*    fDependentFrame;
  152.     ODID            fPartWindowID;
  153. };
  154.  
  155.  
  156.  
  157.  
  158. //-------------------------------------------------------------------------
  159. // Inline methods
  160. //-------------------------------------------------------------------------
  161.  
  162. //=========================================================================
  163. // CFrameProxy
  164. //=========================================================================
  165.  
  166. inline CFrameProxy::CFrameProxy()
  167. {
  168.     fFrame = kODNULL;
  169.     fID = kODNULLID;
  170.     fDraft = kODNULL;
  171. }
  172.     
  173. inline CFrameProxy::~CFrameProxy()
  174. {
  175.     ODSafeReleaseObject(fFrame);
  176. }
  177.     
  178. inline void CFrameProxy::InitFrameProxy(ODID frameID, ODDraft* draft)
  179. {
  180.     ASSERT(draft!=kODNULL, kODErrIllegalNullInput);
  181.     
  182.     fFrame = kODNULL;
  183.     fID = frameID;
  184.     fDraft = draft;
  185. }
  186.     
  187. inline void CFrameProxy::InitFrameProxy(Environment* ev, ODFrame* frame)
  188. {
  189.     ASSERT(frame!=kODNULL, kODErrIllegalNullFrameInput);
  190.     
  191.     this->SetFrame(ev,frame);
  192. }
  193.  
  194. inline ODBoolean CFrameProxy::FrameIsLoaded()
  195. {
  196.     return (fFrame != kODNULL);
  197. }
  198.  
  199. inline ODID CFrameProxy::GetID()
  200. {
  201.     return fID;
  202. }
  203.  
  204. inline ODDraft* CFrameProxy::GetDraft()
  205. {
  206.     return fDraft;
  207. }
  208.  
  209.  
  210. //=========================================================================
  211. // CFrameInfo
  212. //=========================================================================
  213.  
  214. inline ODBoolean CFrameInfo::IsFrameActive()
  215. {
  216.     return fFrameActive;
  217. }
  218.  
  219. inline void CFrameInfo::SetFrameActive(ODBoolean active)
  220. {
  221.     fFrameActive = active;
  222. }
  223.  
  224. inline ODBoolean CFrameInfo::FrameNeedsReactivating()
  225. {
  226.     return fFrameReactivate;
  227. }
  228.  
  229. inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
  230. {
  231.     fFrameReactivate = reactivate;
  232. }
  233.  
  234. inline ODFacet* CFrameInfo::GetActiveFacet()
  235. {
  236.     return fActiveFacet;
  237. }
  238.  
  239. inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
  240. {
  241.     fActiveFacet = facet;
  242. }
  243.  
  244. inline ODFrame* CFrameInfo::GetSourceFrame(Environment* ev)
  245. {
  246.     return (fSourceFrame->GetFrame(ev));
  247. }
  248.  
  249. inline ODBoolean CFrameInfo::HasSourceFrame()
  250. {
  251.     return (fSourceFrame != kODNULL);
  252. }
  253.  
  254. inline ODFrame* CFrameInfo::GetDependentFrame(Environment* ev)
  255. {
  256.     return (fDependentFrame->GetFrame(ev));
  257. }
  258.  
  259. inline ODBoolean CFrameInfo::HasDependentFrame()
  260. {
  261.     return (fDependentFrame != kODNULL);
  262. }
  263.  
  264. inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
  265. {
  266.     fShouldDisposeWindow = should;
  267. }
  268.  
  269. inline ODBoolean CFrameInfo::ShouldDisposeWindow()
  270. {
  271.     return fShouldDisposeWindow;
  272. }
  273.  
  274. #endif
  275.  
  276.